import HttpKit from '../../utils/http-kit'

export default {
  /**
   * @description 获得省列表
   * @returns {provinceList}
   */
  getProvinceList () {
    return HttpKit.get('/district/getAllProvinces', {}).then(
      res => res.data
    )
  },
  /**
   * @description 通过省获得省下面的所有市
   * @param province 省名
   * @returns {cityList}
   */
  getCityList (province) {
    return HttpKit.get('district/getAllCitiesByProvinces/' + province, {}).then(
      res => res.data
    )
  },
  /**
   *@description 通过city获取city下面的所有区
   * @param city 市名
   * @returns {districNametList}
   */
  getDistrictList (city) {
    return HttpKit.get('/district/getAllDistrictsByCity/' + city, {}).then(
      res => res.data
    )
  },
  /**
   * @description 通过省市区获得该省市区下的小区列表
   * @param province
   * @param city
   * @param district
   * @returns {coummnityList}
   */
  getCommunityList (province, city, district) {
    return HttpKit.post('/communityManage/community/getCommunitiesByParams', {'province': province, 'city': city, 'district': district}).then(
      res => res.data
    )
  },
  /**
   *@description 根据城市名获取省市区信息
   * @param city
   * @returns {districtList>}
   */
  getDistrictListByCity (city) {
    return HttpKit.get('/districts/city/' + city, {pageNumber: '0', pageSize: '10000'}).then(
      res => res.data
    )
  }
}
